//
//  ZHAPMManager.m
//  ZYT_IOS
//
//  Created by 正合适 on 2018/1/18.
//  Copyright © 2018年 正合适. All rights reserved.
//

#import "ZHAPMManager.h"
#import "ZHAPMMacro.h"
#import "ZHFPSLabel.h"
#import "ZHMainRunloopObserver.h"

@interface ZHAPMManager ()
/**fps显示*/
@property (nonatomic, strong) ZHFPSLabel *fpsLabel;
/**runloop observer*/
@property (nonatomic, strong) ZHMainRunloopObserver *mainLoopObserver;
@end

@implementation ZHAPMManager

+ (instancetype)shareInstance {
    static ZHAPMManager *manager = nil;
    static dispatch_once_t token;
    dispatch_once(&token, ^{
        manager = [[ZHAPMManager alloc] init];
    });
    return manager;
}

+ (void)registerManager {
    [[ZHAPMManager shareInstance] createFPSLable];
    [[ZHAPMManager shareInstance] startRunloopObserver];
}

+ (void)showFps {
    [[ZHAPMManager shareInstance] createFPSLable];
}

- (void)createFPSLable {
#if DEBUG
    if (![ZHAPMManager shareInstance].fpsLabel) {
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [ZHAPMManager shareInstance].fpsLabel = [[ZHFPSLabel alloc] initWithFrame:CGRectMake(0, 50, 80, 30)];
            [[UIApplication sharedApplication].keyWindow addSubview:[ZHAPMManager shareInstance].fpsLabel];
        });
    }
#endif
}

- (void)startRunloopObserver {
    if (!_mainLoopObserver) {
        _mainLoopObserver = [[ZHMainRunloopObserver alloc] init];
    }
}

- (void)exchangeNetMethod {
    
}





@end
